/*
 * StatusInfo.java
 *
 * Created on 27 Август 2010 г., 11:13
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package protocol;

import DrawControls.icons.*;
import chatty.util.ResBundle;

/**
 *
 * @author Vladimir Kryukov
 */
public class StatusInfo {
    public final ImageList statusIcons;
    public final int[] statusIconIndex;
    private static final String[] statusNames = {
        "status_offline",
        "status_online",
		"status_ffc",
        "status_away",
		"status_dnd",
        "status_na",
		
		"status_evil",
        "status_depression",
        "status_home",
        "status_work",
        "status_lunch",
		
        "status_invisible",
        "status_not_in_list"
    };
    
    /** Creates a new instance of StatusInfo */
    public StatusInfo(ImageList statuses, int[] index) {
        statusIcons = statuses;
        statusIconIndex = index;
        if (null == statuses.iconAt(index[Status.I_STATUS_NOT_IN_LIST])) {
            index[Status.I_STATUS_NOT_IN_LIST] = index[Status.I_STATUS_OFFLINE];
        }
    }
    public String getName(byte statusIndex) {
        return ResBundle.getString(statusNames[statusIndex]);
    }
    public String getName(Status status) {
        return getName((null == status) ? Status.I_STATUS_OFFLINE : status.getStatusIndex());
    }

    public Icon getIcon(byte statusIndex) {
        return statusIcons.iconAt(statusIconIndex[statusIndex]);
    }
    public Icon getIcon(Status status) {
        return getIcon((null == status) ? Status.I_STATUS_OFFLINE : status.getStatusIndex());
    }
    public int getWidth(Status status) {
        if ((null == status) || (Status.offlineStatus == status)) {
            return 29;
        }
		return 29;
    }
    public final boolean isAway(byte statusIndex) {
        switch (statusIndex) {
			case Status.I_STATUS_OFFLINE:
            case Status.I_STATUS_FFC:
            case Status.I_STATUS_AWAY:
            case Status.I_STATUS_DND:
            case Status.I_STATUS_NA:
            case Status.I_STATUS_INVISIBLE:
			case Status.I_STATUS_NOT_IN_LIST:
                return true;
        }
        return false;
    }
}
